package com.example.springbootexamples.http;

import com.fasterxml.jackson.databind.ObjectMapper;
import edu.emory.mathcs.backport.java.util.Arrays;
import org.junit.Test;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;

import javax.ws.rs.core.MultivaluedHashMap;

public class T {

    @Test
    public void t(){

        ObjectMapper mapper=new ObjectMapper();
        RestTemplate restTemplate=new RestTemplate();

        //restTemplate.setInterceptors(Arrays.asList(new ));
        HttpHeaders httpHeaders=new HttpHeaders();
        /*MultivaluedHashMap multivaluedHashMn=new MultivaluedHashMap();
        multivaluedHashMn.add("a","b");*/

        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);

        MultiValueMap<String, String> map= new LinkedMultiValueMap<String, String>();
        map.add("email","a@1.com");
                HttpEntity<Object> httpEntity=new HttpEntity<>(map,headers);
        ResponseEntity<String> responseEntity=restTemplate.postForEntity("http://localhost:8080/a",httpEntity,String.class);
        HttpHeaders httpHeaders1=responseEntity.getHeaders();
        System.out.println(httpHeaders1);



    }
}
